package com.sun.chunqiugeneratorbasic.generator;

import com.sun.chunqiugeneratorbasic.model.MainTemplateConfig;

import java.io.File;
import java.io.IOException;

import static com.sun.chunqiugeneratorbasic.generator.StaticGenerator.copyFileByRecursive;

public class MainGenerator {

    public static void doGenerator(MainTemplateConfig mainTemplateConfig) {
        String projectPath = System.getProperty("user.dir");
        String inputPath = projectPath;
        String outputPath = projectPath;
        File inputFile = new File(new File(inputPath).getParentFile().toString() + "/chunqiu-generator-demo-project/acm-template");
    }

    public static void main(String[] args) {
        String projectPath = System.getProperty("user.dir");
        String inputPath = projectPath + File.separator + "chunqiu-generator-demo-project" + File.separator + "acm-template";
        String outputPath = projectPath;
        File inputFile = new File(inputPath);
        File outputFile = new File(outputPath);
        try {
            StaticGenerator.copyFileByRecursive(inputFile, outputFile);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


        String DynamicinputPath = new File(projectPath).getParentFile().toString() + File.separator + "chunqiu-generator-basic" + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "templates" + File.separator + "MainTemplate.java.ftl";
        String DynamicoutputPath = projectPath + File.separator + "acm-template\\src\\com\\yupi\\acm\\MainTemplate.java";
//        String DynamicinputPath = projectPath + File.separator + "chunqiu-generator-basic" + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "templates" + File.separator + "MainTemplate.java.ftl";
//        String DynamicoutputPath = projectPath + File.separator + "acm-template\\src\\com\\yupi\\acm\\MainTemplate.java";
        MainTemplateConfig mainTemplateConfig = new MainTemplateConfig();
        mainTemplateConfig.setAuthor("chunqiu");
        mainTemplateConfig.setOutputText("求和结果：");
        mainTemplateConfig.setLoop(false);
        DynamicGenerator.doGenerator(DynamicinputPath, DynamicoutputPath, mainTemplateConfig);
    }
}

